package filter;

import javax.servlet.*;
import java.io.IOException;

/**
 * 08-Filter注解开发
 */
//@WebFilter(
//        filterName = "Demo08Filter",
//        urlPatterns = {
//                "/demo01", "/demo02"
//        },
//        initParams = {
//                @WebInitParam(
//                        name = "encoding", value = "utf-8"
//                ),
//                @WebInitParam(
//                        name = "encoding2", value = "gbk"
//                )
//        },
//        dispatcherTypes = {
//                DispatcherType.REQUEST,
//                DispatcherType.FORWARD,
//                DispatcherType.INCLUDE,
//                DispatcherType.ERROR
//        },
//        servletNames = {
//                "Demo01Servlet", "Demo02Servlet"
//        }
//
//)
public class Demo08Filter implements Filter {

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        System.out.println("Demo08Filter 过滤");
        chain.doFilter(request, response);//相当于执行Demo01Servlet
        System.out.println("Demo08Filter 放行");

    }
}
